from State import State
from os.path import isfile
from config import get_config
from calcPower import *

if isfile("./config.py"):
    from config import get_config

others_datas = get_config()["others"]
pv_datas = get_config()["PV"]


class Mode_Init(State):
    def handle(self, fsm):
        print("进入初始化模式")
        self.pf.create_pv(pv_datas["本振源A"]).put(others_datas["本振源A设定值"])
        self.pf.create_pv(pv_datas["本振源B"]).put(others_datas["本振源B设定值"])
        self.pf.create_pv(pv_datas["幅度KP"]).put(others_datas["幅度KP"])
        self.pf.create_pv(pv_datas["幅度KI"]).put(others_datas["幅度KI"])
        # self.pf.create_pv(pv_datas["幅度驱动"]).put(calc_Power_to_AI(self.pf.create_pv(pv_datas["开环功率设置"]).get()))
        return fsm.mode_openloop
